package com.dreamwhale.machinery.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dreamwhale.machinery.config.DataResult;
import com.dreamwhale.machinery.dao.VipInfoMapper;
import com.dreamwhale.machinery.entity.VipInfo;
import com.dreamwhale.machinery.service.VipInfoService;
import org.apache.velocity.runtime.directive.Foreach;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Author
 * @since 2020-07-01
 */
@RestController
@RequestMapping("/vipInfo")
public class VipInfoController {

    @Resource
    private VipInfoService vipInfoService;

    @Resource
    private VipInfoMapper vipInfoMapper;

    @RequestMapping("inquiryVipInfo")
    /**
     * @MethodName : inquiryVipInfo
     * @Description : 查询会员基础信息
     * @param :
     * @Author : DragonUncle
     * @Data : 9:25 2020/7/9
     * @return :
     */
    public DataResult inquiryVipInfo() {
        HashMap<String, Object> map = new HashMap<>();
        HashMap<String, Object> map2 = new HashMap<>();
        HashMap<String, Object> map3 = new HashMap<>();
        QueryWrapper<VipInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("vip_level", 1);
        List<VipInfo> list = vipInfoMapper.selectList(queryWrapper);
        map.put("name", "vip1");
        map.put("list", list);

        QueryWrapper<VipInfo> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.eq("vip_level", 2);
        List<VipInfo> list2 = vipInfoMapper.selectList(queryWrapper2);
        map2.put("name", "vip2");
        map2.put("list", list2);

        QueryWrapper<VipInfo> queryWrapper3 = new QueryWrapper<>();
        queryWrapper3.eq("vip_level", 3);
        List<VipInfo> list3 = vipInfoMapper.selectList(queryWrapper3);

        map3.put("name", "vip3");
        map3.put("list", list3);

        List<HashMap<String, Object>> resultList = new ArrayList<>();
        resultList.add(map);
        resultList.add(map2);
        resultList.add(map3);
        return DataResult.ok(resultList);
    }
}

